
<%@page import="ll.sms.util.SmsUtil"%><%@ page language="java" import="java.util.*,ll.sms.web.*,ll.sms.pojo.*,ll.sms.web.*"  pageEncoding="UTF-8"%>
<%@page import="ll.sms.util.SmsConstant"%>
<%@page import="java.sql.Timestamp"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="java.net.URLDecoder"%>
<%
try{
SmsAdmin smsAdmin = new SmsAdmin();
String pass=ParamUtils.getParameter(request,"apwd");
String repass=ParamUtils.getParameter(request,"reapwd");
if(pass==null || pass.trim().equals("") || !pass.equals(repass)){
	out.print( "{success:false,errors:{msg:'密码不匹配..'}}");
	return;
}

RequestUtils.populate(smsAdmin,request);
smsAdmin.setAregisttime(new Timestamp( new Date().getTime()));
smsAdmin.setAid(SmsUtil.getPrimaryKey());

String defaultchannel = smsAdmin.getAdefaultchannel();
if(StringUtils.isBlank(defaultchannel)){
out.print( "{success:false,errors:{msg:'未配置通道'}}");
return;
}


if(!SmsUtil.checkUsername(smsAdmin.getAuname())){
out.print( "{success:false,errors:{msg:'用户名允许的字符为:英文字母、中文、下划线,长度为4-32位'}}");
return;
}


defaultchannel = URLDecoder.decode(defaultchannel,"UTF-8");
defaultchannel = defaultchannel.split("=")[1];
smsAdmin.setAdefaultchannel(defaultchannel);
//添加业务员
if("operator".equals(request.getParameter("admintype"))){
smsAdmin.setArank(SmsConstant.OPERATOR_TYPE);
}else{
//添加代理
smsAdmin.setArank(SmsConstant.PROXY_TYPE);
}

out.print(WebBusinessImpl.getInstance().addProxy(smsAdmin));

}catch(Exception e){
	e.printStackTrace();
	out.print( "{success:false,errors:{msg:'添加失败！！'}}");
}
//out.print( "{success:true}");
%>
